package com.mo;

import com.mo.ext.OrderMapper;
import com.mo.pojo.Order;
import com.mo.pojo.OrderQueryParam;
import org.junit.Assert;
import org.junit.Test;

/**
 * 自动赋值映射mapstruct, lombok版本与mapstruct版本有影响
 *
 * @author moon.pan
 * @program mo-all
 * @apiNote
 * @since 2022/3/21
 */
public class MapStructDemo {

    @Test
    public void entity2queryParam() {
        Order order = new Order();
        order.setId(12345L);
        order.setOrderSn("orderSn");
        order.setOrderType(0);
        order.setReceiverKeyword("keyword");
        order.setSourceType(1);
        order.setStatus(2);

//        OrderMapper mapper = Mappers.getMapper(OrderMapper.class);
//        OrderQueryParam orderQueryParam = mapper.entity2queryParam(order);

        OrderQueryParam orderQueryParam = OrderMapper.INSTANCE.entity2queryParam(order);
        Assert.assertEquals(orderQueryParam.getOrderSn(), order.getOrderSn());
        Assert.assertEquals(orderQueryParam.getOrderType(), order.getOrderType());
        Assert.assertEquals(orderQueryParam.getReceiverKeyword(), order.getReceiverKeyword());
        Assert.assertEquals(orderQueryParam.getSourceType(), order.getSourceType());
        Assert.assertEquals(orderQueryParam.getStatus(), order.getStatus());
        System.out.println(orderQueryParam.getStatus());
    }
}
